/**
 * BBD Service Inc
 * All Rights Reserved @2018
 */
package com.xiaoke.web.controller;

import com.xiaoke.utils.AjaxMsg;
import com.xiaoke.utils.OSSClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * 媒体中心
 *
 * @author
 */
@Controller
@RequestMapping("/media")
public class MediaController {
    @Autowired
    private OSSClientUtils ossClientUtils;

    @RequestMapping(value = "/uploadImages")
    @ResponseBody
    public AjaxMsg uploadImages(MultipartFile[] file) {
        AjaxMsg ajaxMsg = new AjaxMsg();
        try {
            List<String> urls = ossClientUtils.uploadImgs(file);
            ajaxMsg.setDatas(urls);
            ajaxMsg.setCode(AjaxMsg.SUCCESS);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ajaxMsg;
    }

}
